﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SimhoppKjellsFavoriterVT13
{
    public class Contestant : Person
    {
        public List<Jump> listOfJumps = new List<Jump>();


        public void addJump(Jump dive)
        {
            listOfJumps.Add(dive);
        }


        public Jump getJump(int jump)
        {
            int i = 1;
            foreach (Jump j in listOfJumps)
            {
                if (jump == i)
                {
                    return j;
                }
                i++;
            }
            return null;
        }

        public void removeJump(int jump)
        {
            int i = 1;
            foreach (Jump j in listOfJumps)
            {
                if (jump == i)
                {
                    listOfJumps.Remove(j);
                    return;
                }
                i++;
            }
        }


        public void removeJump(Jump j)
        {
            listOfJumps.Remove(j);
        }

        public float getScoreForJumpAndJudge(int jump, int judge)
        {
            int i = 1;
            foreach (Jump j in listOfJumps)
            {
                if (i == jump)
                {
                    return j.calculatePointsForJudge(judge);
                }
                i++;
            }
            return 0f;
        }

        public Judge getJudgeFromJump(int jump, int judge)
        {
            int i = 1;
            foreach (Jump j in listOfJumps)
            {
                if (i == jump)
                {
                    return j.getJudge(judge);
                }
                i++;
            }
            return null;
        }

        public float getTotalScore()
        {
            float totalScore = 0;

            foreach (Jump j in listOfJumps)
            {
                totalScore += j.calculateTotalPoints();
            }

            return totalScore;
        }
    }
}
